package github.kawaiior.botapiserver.config;

import github.kawaiior.botapiserver.interceptor.BotApiInterceptor;
import github.kawaiior.botapiserver.interceptor.TokenInterceptor;
import github.kawaiior.botapiserver.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private UserMapper userMapper;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TokenInterceptor(userMapper)).addPathPatterns("/api/admin/**");
        registry.addInterceptor(new BotApiInterceptor()).addPathPatterns("/api/bot/**");
    }
}

